import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class code1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for(int i=0;i<n;i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();

            System.out.println(you(a,b,c));
        }
    }

    private static int you(int a,int b,int c) {
        int ret = 0;
        int two = Math.min(a,Math.min(b,c));
        if(two != 0) {
            ret += two*2;
            a -= two;
            b -= two;
            c -= two;
        }

        if(b >= 2) {
            ret += (b-1);
        }

        return ret;
    }
}